package com.trisan;



import java.util.List;

import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;


public class DataForDropDown extends TagSupport{
	
	
	
	
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public int doEndTag(){
		WebApplicationContext ctx=ContextLoader.getCurrentWebApplicationContext();
		Object d=ctx.getBean(DeptDAO.class);
		DeptDAO deptDAO=(DeptDAO)d;
		JspWriter out=pageContext.getOut();
		try{
			
			List<Dept> ids=deptDAO.getDepts();
			out.print("<select name=\"did\" id=\"deptid\">");
			for(Object o:ids){
				Dept s=(Dept)o;
				out.println("<option value=\""+s.getDeptid()+"\">"+s.getDeptid()+"</option>");
			}
			out.print("</select>");
		}
		catch(Exception e1){
			e1.printStackTrace();
		}
		return EVAL_PAGE;
	}

}
